package seqlist.stack_queue.queue.impl;

import bin_tree.heap.MaxHeap;
import seqlist.stack_queue.queue.MyQueue;

/**
 * @author yuisama
 * @date 2023/03/31 19:01
 * 基于最大堆的优先级队列
 **/
public class PriorityQueue implements MyQueue<Integer> {
    // 使用最大堆作为存储元素的集合
    private MaxHeap heap = new MaxHeap();
    @Override
    public void offer(Integer val) {
        heap.add(val);
    }

    @Override
    public Integer poll() {
        return heap.extractMax();
    }

    @Override
    public Integer peek() {
        return heap.peekMax();
    }
}